//
//  LoginViewController.m
//  SweetComics
//
//  Created by dlios on 15-1-28.
//  Copyright (c) 2015年 LeeZhe. All rights reserved.
//

#import "LoginViewController.h"
#import "ResignViewController.h"
@interface LoginViewController ()

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 登陆
    self.title = @"登陆";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
    
    
    // 账号
    self.accout = [[UITextField alloc] initWithFrame:CGRectMake(20, 84, self.view.frame.size.width - 40, 30)];
    _accout.borderStyle = UITextBorderStyleRoundedRect;
    _accout.placeholder = @"账号";
    [self.view addSubview:_accout];
    [_accout release];
    // 密码
    self.passWord = [[UITextField alloc] initWithFrame:CGRectMake(20, 134, self.view.frame.size.width - 40, 30)];
    _passWord.borderStyle = UITextBorderStyleRoundedRect;
    _passWord.placeholder = @"密码";
    _passWord.secureTextEntry = YES;
    [self.view addSubview:self.passWord];
    [_passWord release];
    
    self.resign = [UIButton buttonWithType:UIButtonTypeSystem];
    [_resign setTitle:@"注册" forState:UIControlStateNormal];
    _resign.layer.cornerRadius = 5;
    _resign.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.2];
    _resign.frame = CGRectMake(20, 204, (self.view.frame.size.width - 120) / 2, 30);
    _resign.tintColor = [UIColor whiteColor];
    [_resign addTarget:self action:@selector(buttonAction1:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.resign];
    
    self.login = [UIButton buttonWithType:UIButtonTypeSystem];
    [_login setTitle:@"登陆" forState:UIControlStateNormal];
    _login.layer.cornerRadius = 5;
    _login.frame = CGRectMake(20 + (self.view.frame.size.width - 120) / 2 + 80, 204, (self.view.frame.size.width - 120) / 2, 30);
    _login.tintColor = [UIColor whiteColor];
    _login.backgroundColor = [UIColor colorWithRed:0 green:0.5 blue:1 alpha:0.7];
    [_login addTarget:self action:@selector(buttonAction2:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.login];
    
    
}
// 注册按钮
- (void)buttonAction1:(UIButton *)button
{
    self.hidesBottomBarWhenPushed = YES;
    ResignViewController *resignVC = [[ResignViewController alloc] init];
    [self.navigationController pushViewController:resignVC animated:YES];
    self.hidesBottomBarWhenPushed = NO;
    [resignVC release];
    
    
    
    
    
}

// 登陆按钮
- (void)buttonAction2:(UIButton *)button
{
    if ([self.accout.text isEqualToString:@""] || [self.passWord isEqual:@""] ) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"账号和密码输入有误" delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:nil, nil];
        [alertView show];
        [alertView release];
    }
//    else if (self.accout.text){
//    [self.navigationController popToRootViewControllerAnimated:YES];
//    }
}


- (void)dealloc
{
    [_accout release];
    [_passWord release];
    [_resign release];
    [_login release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
